package me.magicall.db.sql;

public abstract class AbsHasAs extends SqlElementTemplate implements HasAs {

	private SqlElement sqlElement;
	private As as;

	protected AbsHasAs() {
		super();
	}

	protected AbsHasAs(final SqlElement toSqlable) {
		super();
		sqlElement = toSqlable;
	}

	protected AbsHasAs(final SqlElement toSqlable, final As as) {
		super();
		sqlElement = toSqlable;
		this.as = as;
	}

	@Override
	public StringBuilder appendTo(final StringBuilder sb) {
		getToSqlable().appendTo(sb);
		final As as = getAs();
		if (as != null) {
			as.appendTo(sb);
		}
		return sb;
	}

	public As getAs() {
		return as;
	}

	public void setAs(final As as) {
		this.as = as;
	}

	public void setAs(final String asName) {
		setAs(new As(asName));
	}

	public SqlElement getToSqlable() {
		return sqlElement;
	}

	protected void setToSqlable(final SqlElement sqlElement) {
		this.sqlElement = sqlElement;
	}
}